#pip install -i https://pypi.douban.com/simple pyecharts -U
import pyecharts.options as opts
import Line
from matplotlib import pyplot as plt
#导入csv模块
import csv
filename = '3.csv'

with open(filename) as f:
        #创建一个阅读器：将f传给csv.reader
        reader = csv.reader(f)
        #使用csv的next函数，将reader传给next，将返回文件的下一行
        header_row = next(reader)


with open(filename) as f:
    reader = csv.DictReader(f)
    index = [row[header_row[0]] for row in reader]
with open(filename) as f:
    reader = csv.DictReader(f)
    b1 = [row[header_row[1]] for row in reader]
with open(filename) as f:
    reader = csv.DictReader(f)
    b2 = [row[header_row[2]] for row in reader]
with open(filename) as f:
    reader = csv.DictReader(f)
    b3 = [row[header_row[3]] for row in reader]
with open(filename) as f:
    reader = csv.DictReader(f)
    b4 = [row[header_row[4]] for row in reader]
with open(filename) as f:
    reader = csv.DictReader(f)
    b5 = [row[header_row[5]] for row in reader]
with open(filename) as f:
    reader = csv.DictReader(f)
    b6 = [row[header_row[6]] for row in reader]
with open(filename) as f:
    reader = csv.DictReader(f)
    b7 = [row[header_row[7]] for row in reader]
with open(filename) as f:
    reader = csv.DictReader(f)
    b8 = [row[header_row[8]] for row in reader]
with open(filename) as f:
    reader = csv.DictReader(f)
    b9 = [row[header_row[9]] for row in reader]
with open(filename) as f:
    reader = csv.DictReader(f)
    b10 = [row[header_row[10]] for row in reader]

c = (
        Line()
        .add_xaxis(index)
        .add_yaxis(
            header_row[1],
            b1,
            markpoint_opts=opts.MarkPointOpts(data=[opts.MarkPointItem(type_="max"),opts.MarkPointItem(type_="min")]),
            is_smooth=True,
            is_connect_nones=True,
        )
       .add_yaxis(
            header_row[2],
            b2,
            markpoint_opts=opts.MarkPointOpts(data=[opts.MarkPointItem(type_="max"),opts.MarkPointItem(type_="min")]),
            is_smooth=True,
            is_connect_nones=True,
        )
       .add_yaxis(
            header_row[3],
            b3,
            markpoint_opts=opts.MarkPointOpts(data=[opts.MarkPointItem(type_="max"),opts.MarkPointItem(type_="min")]),
            is_smooth=True,
            is_connect_nones=True,
        )
       .add_yaxis(
            header_row[4],
            b4,
            markpoint_opts=opts.MarkPointOpts(data=[opts.MarkPointItem(type_="max"),opts.MarkPointItem(type_="min")]),
            is_smooth=True,
            is_connect_nones=True,
        )
       .add_yaxis(
            header_row[5],
            b5,
            markpoint_opts=opts.MarkPointOpts(data=[opts.MarkPointItem(type_="max"),opts.MarkPointItem(type_="min")]),
            is_smooth=True,
            is_connect_nones=True,
        )
      .add_yaxis(
            header_row[6],
            b6,
            markpoint_opts=opts.MarkPointOpts(data=[opts.MarkPointItem(type_="max"),opts.MarkPointItem(type_="min")]),
            is_smooth=True,
            is_connect_nones=True,
        )
      .add_yaxis(
            header_row[7],
            b7,
            markpoint_opts=opts.MarkPointOpts(data=[opts.MarkPointItem(type_="max"),opts.MarkPointItem(type_="min")]),
            is_smooth=True,
            is_connect_nones=True,
        )
      .add_yaxis(
            header_row[8],
            b8,
            markpoint_opts=opts.MarkPointOpts(data=[opts.MarkPointItem(type_="max"),opts.MarkPointItem(type_="min")]),
            is_smooth=True,
            is_connect_nones=True,
        )
      .add_yaxis(
            header_row[9],
            b9,
            markpoint_opts=opts.MarkPointOpts(data=[opts.MarkPointItem(type_="max"),opts.MarkPointItem(type_="min")]),
            is_smooth=True,
            is_connect_nones=True,
        )
      .add_yaxis(
            header_row[10],
            b10,
            markpoint_opts=opts.MarkPointOpts(data=[opts.MarkPointItem(type_="max"),opts.MarkPointItem(type_="min")]),
            is_smooth=True,
            is_connect_nones=True,
        )
        .set_global_opts(title_opts=opts.TitleOpts(title="词云趋势"))
    )
c.render('词云趋势3.html')